import matplotlib.pyplot as plt
import numpy as np

# 解决中文乱码
plt.rcParams['font.family'] = 'SimHei'  # 设置中文黑体
plt.rcParams['axes.unicode_minus'] = False  # 解决负号'-'显示为方块的问题

def generate_radar_chart(scores_dict, output_path="radar_chart.png"):
    labels = list(scores_dict.keys())
    scores = list(scores_dict.values())

    angles = np.linspace(0, 2 * np.pi, len(labels), endpoint=False).tolist()
    scores += scores[:1]  # 闭合
    angles += angles[:1]

    fig, ax = plt.subplots(figsize=(6, 6), subplot_kw=dict(polar=True))
    ax.plot(angles, scores, 'o-', linewidth=2, label="能力评分")
    ax.fill(angles, scores, alpha=0.25)

    ax.set_thetagrids(np.degrees(angles[:-1]), labels)
    ax.set_ylim(0, 100)
    ax.set_title("候选人能力雷达图", fontsize=16)
    ax.grid(True)
    plt.tight_layout()
    plt.savefig(output_path, dpi=300)
    plt.close()
